import { Component, OnInit } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router';
import { DefaultLanguageService } from '@services/default-language.service';
import {TranslateService} from '@ngx-translate/core';

@Component({
  selector: 'app-login-password',
  templateUrl: './login-password.page.html',
  styleUrls: ['./login-password.page.scss'],
})
export class LoginPasswordPage implements OnInit {

  private i18n:any = {
    changeLoginPwd:"Change Login Password",
    resetLoginPwd:"Reset Login Password"
  };

  public techs = [
    {
      'id':1,
      'title': this.i18n.changeLoginPwd,
      'icon': 'angular',
      'path':'/tabs/myAccount/setting/account-security/login-password/change-password'
    },
    {
      'id':2,
      'title': this.i18n.resetLoginPwd,
      'icon': 'css3',
      'path':'/tabs/myAccount/setting/account-security/login-password/reset-password'
    }
  ]

  constructor(
    private router: Router,
    private defaultLanguageService:DefaultLanguageService,
    private translate:TranslateService) { }

  ngOnInit() {
    this.initLanguage();
  }

  initLanguage(){
    let defaultLanguage = this.defaultLanguageService.getDefaultLanguage();
    this.translate.setDefaultLang(defaultLanguage);
    this.translate.use(defaultLanguage);
    this.translate.get('myAccount.setting.accountScurity.loginPwdFunction').subscribe((obj)=>{
      this.i18n = obj;
      this.techs = [
        {
          'id':1,
          'title': this.i18n.changeLoginPwd,
          'icon': 'angular',
          'path':'/tabs/myAccount/setting/account-security/login-password/change-password'
        },
        {
          'id':2,
          'title': this.i18n.resetLoginPwd,
          'icon': 'css3',
          'path':'/tabs/myAccount/setting/account-security/login-password/reset-password'
        }
      ]
    }); 
  }

  showDetail(techId){
    const tech = this.techs.find(tech => tech.id === techId);
    this.router.navigate([tech.path]);
  }

}
